package com.itboye.jmsfhz.app.ui.web;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Observable;
import java.util.Observer;

import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.itboye.core.alert.ByAlert;
import com.itboye.core.object.BaseActivity;
import com.itboye.jmsfhz.R;

public class WebActivity extends BaseActivity {
	private WebView webview;
	private TextView txt_title;
	private String url;
	private String title;
	private ProgressBar myProgressBar;
	private LinearLayout linWeb;

	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.activity_web;
	}

	@Override
	public void onMyCreate() {
		title = getIntent().getStringExtra("title");
		txt_title.setText(title);
		url = getIntent().getStringExtra("url");
		System.out.println("titletitletitletietle" + url);

		webview.setVisibility(View.VISIBLE);
		linWeb.setVisibility(View.GONE);
		myProgressBar = new ProgressBar(this);
		if (url == null) {
			linWeb.setVisibility(View.VISIBLE);
			webview.setVisibility(View.GONE);
		}
		webview.setWebChromeClient(new WebChromeClient() {
			@Override
			public void onProgressChanged(WebView view, int newProgress) {
				if (newProgress == 100) {
					myProgressBar.setVisibility(View.INVISIBLE);
				} else {
					if (View.INVISIBLE == myProgressBar.getVisibility()) {
						myProgressBar.setVisibility(View.VISIBLE);
					}
					myProgressBar.setProgress(newProgress);
				}
				super.onProgressChanged(view, newProgress);
			}

		});
		webview.loadUrl(url);
	}

	public void imgback(View view) {
		this.finish();
	}

}
